/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "pedido_det", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PedidoDet.findAll", query = "SELECT p FROM PedidoDet p"),
    @NamedQuery(name = "PedidoDet.findByPedidoCab", query = "SELECT p FROM PedidoDet p WHERE p.pedidoCab = :pedidoCab"),
    @NamedQuery(name = "PedidoDet.findByCantidad", query = "SELECT p FROM PedidoDet p WHERE p.cantidad = :cantidad"),
    @NamedQuery(name = "PedidoDet.findByPrecio", query = "SELECT p FROM PedidoDet p WHERE p.precio = :precio")})
public class PedidoDet implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "pedido_cab", nullable = false)
    private Integer pedidoCab;
    @Column(name = "cantidad")
    private Integer cantidad;
    @Column(name = "precio")
    private Integer precio;
    @JoinColumn(name = "prod_cod", referencedColumnName = "prod_cod", nullable = false)
    @ManyToOne(optional = false)
    private Productos prodCod;
    @JoinColumns({
        @JoinColumn(name = "dseccion", referencedColumnName = "idseccion", nullable = false),
        @JoinColumn(name = "iddeposito", referencedColumnName = "iddeposito", nullable = false),
        @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false)})
    @ManyToOne(optional = false)
    private Seccion seccion;
    @JoinColumn(name = "pedido_cab", referencedColumnName = "idpedido_cab", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private PedidoCab pedidoCab1;

    public PedidoDet() {
    }

    public PedidoDet(Integer pedidoCab) {
        this.pedidoCab = pedidoCab;
    }

    public Integer getPedidoCab() {
        return pedidoCab;
    }

    public void setPedidoCab(Integer pedidoCab) {
        this.pedidoCab = pedidoCab;
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }

    public Integer getPrecio() {
        return precio;
    }

    public void setPrecio(Integer precio) {
        this.precio = precio;
    }

    public Productos getProdCod() {
        return prodCod;
    }

    public void setProdCod(Productos prodCod) {
        this.prodCod = prodCod;
    }

    public Seccion getSeccion() {
        return seccion;
    }

    public void setSeccion(Seccion seccion) {
        this.seccion = seccion;
    }

    public PedidoCab getPedidoCab1() {
        return pedidoCab1;
    }

    public void setPedidoCab1(PedidoCab pedidoCab1) {
        this.pedidoCab1 = pedidoCab1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pedidoCab != null ? pedidoCab.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PedidoDet)) {
            return false;
        }
        PedidoDet other = (PedidoDet) object;
        if ((this.pedidoCab == null && other.pedidoCab != null) || (this.pedidoCab != null && !this.pedidoCab.equals(other.pedidoCab))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.PedidoDet[ pedidoCab=" + pedidoCab + " ]";
    }
    
}
